package com.study.concurrent.B_ThreadSynchronizedBasic.h_UserMultipleConditionInLock;

/**
 * Created by 赵超 on 2017/3/23
 * 生产者
 */
public class Producer implements Runnable {
    private FileMock mock;
    private Buffer buffer;

    public Producer(FileMock mock, Buffer buffer) {
        this.mock = mock;
        this.buffer = buffer;
    }

    @Override
    public void run() {
        buffer.setPendingLines(true);
        while (mock.hasMoreLines()) {
            String line = mock.getLine();
            buffer.insert(line);
        }
        // 通知缓冲区停止生成更多的行
        buffer.setPendingLines(false);
        System.out.println("=========== ");
    }
}
